var CompanyBankCards = function () {
	
	var options;

    var handle = function () {
    	
        grid.init({
            src: $("#datatable_companybankcards"),
            fixedColumns: 1,
            onSuccess: function (data) { },
            onError: function (data) { },
            dataTable: {
                "pageLength": 10,
                "ajax": {"url": options.path},
                "columnDefs": [{'orderable': false, 'targets': [0]}],
                "columns": [
					{"data": "id", "render": function(data,type,full) {
						return '<div class="btn-group">'+
								'	<a href="#" class="btn blue-madison btn-xs btn-operation" data-toggle="dropdown">'+
								'		<i class="fa fa-cog"></i> ' + message['datatable.operation'] + 
								'	</a>'+
								'	<ul class="dropdown-menu pull-left">'+
								'		<li><a href="' + options.path + '/update/' + full.id + '" data-toggle="modal" data-target="#ajax-modal">修改</a></li>'+
								'		<li><a href="' + options.path + '/delete/' + full.id + '" data-toggle="delete">删除</a></li>'+
								'		<li><a href="' + options.path + '/available:' + !full.available + '/' + full.id + '" data-toggle="available">' + (full.available ? '停用' : '启用') + '</a></li>'+
								'		<li><a href="#">转出</a></li>'+
								'		<li><a href="#">交易明细</a></li>'+
								'	</ul>'+
								'</div>';
					}},
					{"data": "bankName"},
					{"data": "branchName"},
					{"data": "accountName"},
					{"data": "accountNo"},
					{"data": "accountEmail"},
					{"data": "rechargeAccountType", "render": function(data,type,full){
						return message['net.lanelife.casino.caipiao.entity.CompanyBankCard.RechargeAccountType.'+data];
					}},
					{"data": "currentBalance", "class": "right"},
					{"data": "warningAmount", "class": "right"},
					{"data": "usesType", "render": function(data,type,full){
						return message['net.lanelife.casino.caipiao.entity.CompanyBankCard.UsesType.'+data];
					}},
					{"data": "available", "render": function(data,type,full) {
						return data ? '<span class="label label-sm label-success">' + message['net.lanelife.casino.caipiao.entity.Available.TRUE'] + '</span>' : '<span class="label label-sm label-danger">' + message['net.lanelife.casino.caipiao.entity.Available.FALSE'] + '</span>';
					}},
					
					{"data": "createdBy"},
					{"data": "createdDate"},
					{"data": "lastModifiedBy"},
					{"data": "lastModifiedDate"}
				],
                "order": [
                    [1, "asc"]
                ]
            }
        });
        
    };

    return {
        init: function (opts) {
			options = $.extend(true, {
				path: opts.ctx + '/company-bank-card'
			}, opts);
            handle();
        }
    };

}();

